<?php

namespace AdminBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Inflector\Inflector;

/**
 * HuobiMarketKline30min
 *
 * @ORM\Table(name="huobi_market_kline_30min")
 * @ORM\Entity(repositoryClass="AdminBundle\Repository\HuobiMarketKline30minRepository")
 */
class HuobiMarketKline30min
{
    /**
     * @var string
     *
     * @ORM\Column(name="coin", type="string", length=45, nullable=false)
     */
    private $coin = '';

    /**
     * @var integer
     *
     * @ORM\Column(name="time_stamp", type="integer", nullable=false)
     */
    private $timeStamp = '0';

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="coin_time", type="datetime", nullable=false)
     */
    private $coinTime;

    /**
     * @var string
     *
     * @ORM\Column(name="coin_open", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinOpen = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_close", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinClose = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_low", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinLow = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_high", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinHigh = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_amount", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinAmount = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_vol", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinVol = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_count", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinCount = '0.0000000000000000';

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="ctime", type="datetime", nullable=false)
     */
    private $ctime = 'CURRENT_TIMESTAMP';

    /**
     * @var string
     *
     * @ORM\Column(name="client_ip", type="string", length=45, nullable=false)
     */
    private $clientIp;


    /**
     * @var float
     *
     * @ORM\Column(name="k_5mins", type="float", nullable=false)
     */
    private $k5mins = '50.0';

    /**
     * @var float
     *
     * @ORM\Column(name="d_5mins", type="float", nullable=false)
     */
    private $d5mins = '50.0';

    /**
     * @var float
     *
     * @ORM\Column(name="k_10mins", type="float", nullable=false)
     */
    private $k10mins = '50.0';

    /**
     * @var float
     *
     * @ORM\Column(name="d_10mins", type="float", nullable=false)
     */
    private $d10mins = '50.0';

    /**
     * @var float
     *
     * @ORM\Column(name="rsi_5mins", type="float", nullable=false)
     */
    private $rsi5mins = '0.0';

    /**
     * @var float
     *
     * @ORM\Column(name="rsi_10mins", type="float", nullable=false)
     */
    private $rsi10mins = '0.0';

    /**
     * @var float
     *
     * @ORM\Column(name="rsi_20mins", type="float", nullable=false)
     */
    private $rsi20mins = '0.0';

    /**
     * @var float
     *
     * @ORM\Column(name="rsi_30mins", type="float", nullable=false)
     */
    private $rsi30mins = '0.0';

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;


    public function __construct($data, $prefix = '')
    {
        foreach ($data as $key => $value) {
            $var_name = Inflector::camelize($prefix . $key);
            if (property_exists($this, $var_name)) {
                $this->$var_name = $value;
            }
        }
        $this->ctime = new \DateTime();
    }

    public function __call($name, $arguments)
    {
        $prefix = substr($name, 0, 3);
        $var_name = substr($name, 3);

//        $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($var_name));
        $fieldName = Inflector::camelize($var_name);

        if (!property_exists($this, $fieldName)) {
            throw new Exception('not exists.');
        }

        switch ($prefix) {
            case 'get':
                return $this->$fieldName;
            case 'set':
                $this->$fieldName = $arguments[0];
                return $this;
            default:
                throw new Exception('only set or get.');
        }
    }

    public function toArray()
    {
        return ['coin' => $this->coin,
            'time_stamp' => $this->timeStamp,
            'open' => $this->coinOpen,
            'close' => $this->coinClose,
            'high' => $this->coinHigh,
            'low' => $this->coinLow,
            'vol' => $this->coinVol,
            'amount' => $this->coinAmount,
            'count' => $this->coinCount,
        ];
    }

    public function toJson()
    {
        return json_encode($this->toArray());
    }

    /**
     * Set coin
     *
     * @param string $coin
     *
     * @return HuobiMarketKline30min
     */
    public function setCoin($coin)
    {
        $this->coin = $coin;

        return $this;
    }

    /**
     * Get coin
     *
     * @return string
     */
    public function getCoin()
    {
        return $this->coin;
    }

    /**
     * Set timeStamp
     *
     * @param integer $timeStamp
     *
     * @return HuobiMarketKline30min
     */
    public function setTimeStamp($timeStamp)
    {
        $this->timeStamp = $timeStamp;

        return $this;
    }

    /**
     * Get timeStamp
     *
     * @return integer
     */
    public function getTimeStamp()
    {
        return $this->timeStamp;
    }

    /**
     * Set coinTime
     *
     * @param \DateTime $coinTime
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinTime($coinTime)
    {
        $this->coinTime = $coinTime;

        return $this;
    }

    /**
     * Get coinTime
     *
     * @return \DateTime
     */
    public function getCoinTime()
    {
        return $this->coinTime;
    }

    /**
     * Set coinOpen
     *
     * @param string $coinOpen
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinOpen($coinOpen)
    {
        $this->coinOpen = $coinOpen;

        return $this;
    }

    /**
     * Get coinOpen
     *
     * @return string
     */
    public function getCoinOpen()
    {
        return $this->coinOpen;
    }

    /**
     * Set coinClose
     *
     * @param string $coinClose
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinClose($coinClose)
    {
        $this->coinClose = $coinClose;

        return $this;
    }

    /**
     * Get coinClose
     *
     * @return string
     */
    public function getCoinClose()
    {
        return $this->coinClose;
    }

    /**
     * Set coinLow
     *
     * @param string $coinLow
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinLow($coinLow)
    {
        $this->coinLow = $coinLow;

        return $this;
    }

    /**
     * Get coinLow
     *
     * @return string
     */
    public function getCoinLow()
    {
        return $this->coinLow;
    }

    /**
     * Set coinHigh
     *
     * @param string $coinHigh
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinHigh($coinHigh)
    {
        $this->coinHigh = $coinHigh;

        return $this;
    }

    /**
     * Get coinHigh
     *
     * @return string
     */
    public function getCoinHigh()
    {
        return $this->coinHigh;
    }

    /**
     * Set coinAmount
     *
     * @param string $coinAmount
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinAmount($coinAmount)
    {
        $this->coinAmount = $coinAmount;

        return $this;
    }

    /**
     * Get coinAmount
     *
     * @return string
     */
    public function getCoinAmount()
    {
        return $this->coinAmount;
    }

    /**
     * Set coinVol
     *
     * @param string $coinVol
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinVol($coinVol)
    {
        $this->coinVol = $coinVol;

        return $this;
    }

    /**
     * Get coinVol
     *
     * @return string
     */
    public function getCoinVol()
    {
        return $this->coinVol;
    }

    /**
     * Set coinCount
     *
     * @param string $coinCount
     *
     * @return HuobiMarketKline30min
     */
    public function setCoinCount($coinCount)
    {
        $this->coinCount = $coinCount;

        return $this;
    }

    /**
     * Get coinCount
     *
     * @return string
     */
    public function getCoinCount()
    {
        return $this->coinCount;
    }

    /**
     * Set ctime
     *
     * @param \DateTime $ctime
     *
     * @return HuobiMarketKline30min
     */
    public function setCtime($ctime)
    {
        $this->ctime = $ctime;

        return $this;
    }

    /**
     * Get ctime
     *
     * @return \DateTime
     */
    public function getCtime()
    {
        return $this->ctime;
    }

    /**
     * Set clientIp
     *
     * @param string $clientIp
     *
     * @return BaseResource
     */
    public function setClientIp($clientIp)
    {
        $this->clientIp = $clientIp;

        return $this;
    }

    /**
     * Get clientIp
     *
     * @return string
     */
    public function getClientIp()
    {
        return $this->clientIp;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }
}
